//
//  ShoppingHomeCollectionViewCell.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/1/27.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "ShoppingHomeCollectionViewCell.h"

@implementation ShoppingHomeCollectionViewCell

- (void)awakeFromNib {
    // Initialization code
    
    [self adaptiveViewLayout:self];
    self.shareApi=[LQRequestApi sharedInstance];
    self.shareApi.delegate=self;
    
}

//得到分类产品
- (void)getGoodClassifyData:(NSString *)classifyId row:(NSInteger)indexRow{
    self.classifyId = [NSString stringWithFormat:@"%ld",indexRow];
    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    [dic setObject:@"queryMallCategoryGoodsFirstData" forKey:@"method"];
    [dic setObject:classifyId forKey:@"mgcaParentId"];
    self.shareApi.delegate=self;
    [self.shareApi  requestOperationWithDic:dic withPath:SX_RecommentGoods withHttpType:@"POST" withTag:SX_GetRecommentGoods];
}
#pragma   mark---- GetADBanner Request Delegate

-(void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    
    
    if (tag==SX_GetRecommentGoods) {
        
        if (  [[database valueForKey:@"type"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
            
        }else  {
            dispatch_async(dispatch_get_main_queue(), ^{
                NSArray * array = database[@"result"];
                 NSMutableDictionary *data = [NSMutableDictionary dictionary];
                if (array.count > 0) {
                    NSDictionary * dic = array[0];
                    //                self.goodsInfo.text = [NSString stringWithFormat:@"%@",dic[@"mgooName"]];
                    //                NSLog(@"===========%@",self.goodsInfo.text);
                    [data setValue:dic[@"mgooId"] forKey:@"mgooId"];
                    [data setValue:[NSString stringWithFormat:@"%@",dic[@"mgooCategoryId"]] forKey:@"mgooCategoryId"];
                    [data setValue:[NSString stringWithFormat:@"%@",dic[@"appAdertImagUri"]] forKey:@"appAdertImagUri"];
                    [data setValue:[NSString stringWithFormat:@"%@",dic[@"mgooName"]] forKey:@"mgooName"];
                    
                }else{
                    [data setValue:@"" forKey:@"mgooId"];
                    [data setValue:@"" forKey:@"mgooCategoryId"];
                    [data setValue:@"" forKey:@"appAdertImagUri"];
                    [data setValue:@"" forKey:@"mgooName"];
                }
                if (self.callProductBlock) {
                    self.callProductBlock(data);
                }
            });
           
           
        }
    }
}
-(void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
    
 
    
    
}

#pragma mark  调整自适应布局
- (void) adaptiveViewLayout:(UIView *)viewLayout{
    //视图自适应布局
    for (UIView *view in viewLayout.subviews) {
        view.frame = flexibleFrame(view.frame, NO);
        if ([view isKindOfClass:[UITextField class]]) {
            UITextField *viewField = (UITextField *)view;
            CGFloat fontSize = viewField.font.pointSize;
            viewField.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
        }else if ([view isKindOfClass:[UILabel class]]){
            UILabel *viewLabel = (UILabel *)view;
            CGFloat fontSize = viewLabel.font.pointSize;
            viewLabel.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
        }else if ([view isKindOfClass:[UIButton class]]){
            UIButton *viewButton = (UIButton *)view;
            CGFloat fontSize = viewButton.titleLabel.font.pointSize;
            viewButton.titleLabel.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
        }
        UIView *vv =view;
        for (UIView *view in vv.subviews) {
            view.frame = flexibleFrame(view.frame, NO);
            if ([view isKindOfClass:[UITextField class]]) {
                UITextField *viewField = (UITextField *)view;
                CGFloat fontSize = viewField.font.pointSize;
                viewField.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
            }else if ([view isKindOfClass:[UILabel class]]){
                UILabel *viewLabel = (UILabel *)view;
                CGFloat fontSize = viewLabel.font.pointSize;
                viewLabel.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
            }else if ([view isKindOfClass:[UIButton class]]){
                UIButton *viewButton = (UIButton *)view;
                CGFloat fontSize = viewButton.titleLabel.font.pointSize;
                viewButton.titleLabel.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
            }
            
        }
    }
}


@end
